package com.zxjbyte.yiyi.module.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zxjbyte.yiyi.framework.common.domain.api.PageResult;
import com.zxjbyte.yiyi.framework.mybatis.util.Condition;
import com.zxjbyte.yiyi.module.system.convert.OperateLogConvert;
import com.zxjbyte.yiyi.module.system.domain.dto.OperateLogAddDTO;
import com.zxjbyte.yiyi.module.system.domain.entity.OperateLogPO;
import com.zxjbyte.yiyi.module.system.domain.vo.OperateLogListVO;
import com.zxjbyte.yiyi.module.system.mapper.OperateLogMapper;
import com.zxjbyte.yiyi.module.system.service.OperateLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author zhangxingjia
 * @Date 2023/3/13 18:31
 * @Version: 1.0
 */
@Service
public class OperateLogServiceImpl implements OperateLogService {

    @Resource
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult<OperateLogListVO> list() {
        IPage<OperateLogPO> page = operateLogMapper.selectPage(Condition.getSimplePage(), Wrappers.query());
        List<OperateLogListVO> voList = OperateLogConvert.INSTANCE.poListToVoList(page.getRecords());
        return PageResult.of(voList, page);
    }

    @Override
    public void add(OperateLogAddDTO logAddDto) {
        operateLogMapper.insert(OperateLogConvert.INSTANCE.logAddDtoToPo(logAddDto));
    }
}
